import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../components/Layout'),
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'index',
        component: () => import('../views/index')
      },
      {
        path: '/login',
        name: 'login',
        component: () => import('../views/login')
      },
      {
        path: '/register',
        name: 'register',
        component: () => import('../views/register')
      },
      {
        path: '/resetpwd',
        name: 'restepwd',
        component: () => import('../views/resetpwd')
      },
      {
        path: '/allproducts',
        name: 'allProducts',
        component: () => import('../views/allProducts')
      },
      {
        path: '/detail',
        name: 'detail',
        component: () => import('../views/detail')
      },
      {
        path: '/cart',
        name: 'cart',
        component: () => import('../views/cart')
      },
      {
        path: '/order',
        name: 'order',
        component: () => import('../views/order')
      }
    ]
  },
  {
    path: "/*",
    name: "NotFound404",
    redirect: '/404',
    component: () => import('../views/404'),
    children: [
      {
        path: '/404',
        name: '404',
        component: () => import('../views/404')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
